package com.mzy.linear_struct.subject;

/**
 * @Author: codermzy
 * @Date: 2024/04/01/22:01
 * @Description:
 */
public class 错误的集合 {

    class Solution {
        public int[] findErrorNums(int[] nums) {
            int[] arr = new int[nums.length + 1];

            for (int i = 0; i < nums.length; i++) {
                arr[nums[i]]++;
            }
            int[] result = new int[2];
            for (int i = 1; i < arr.length; i++) {
                if (arr[i] == 2) {
                    result[0] = i;
                }else if(arr[i] == 0) {
                    result[1] = i;
                }
            }

            return result;
        }
    }

    public static void main(String[] args) {

    }
}
